<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/pageRc/common/common.jsp"%>

<!DOCTYPE html>
<html lang="en" style="overflow-x: hidden">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-tap-highlight" content="no">

<link rel="stylesheet" href="<%=commonPath%>/pageRc/layui/css/layui.css"
	media="all">
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/common/utils.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/common/msgTool.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/layui/layui.js"></script>

<title>产能分配数据</title>

<script>
	$(function(){

 	})
	//注意：选项卡 依赖 element 模块，否则无法进行工能性操作
	layui.use('element', function() {
		var element = layui.element();

		//…
	});
</script>
<jsp:include page="publicMethod.jsp" />
</head>
<body class="layui-main" style="width: 100%;">
	<blockquote class="layui-elem-quote">产能分配数据</blockquote>
		<form id="createMsgForm" name="createMsgForm" class="layui-form"
			action="">
			<div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-inline">
						<select name="proGroupNo" id="proGroupNo"
							lay-filter="proGroupSelect" style="width: 210;">
								<c:forEach items="${groupList}" var="group">
									<option value="${group.proGroupNo}">${group.proGroupName}</option>
								</c:forEach>
						</select>
					</div>
					<div class="layui-inline">
						<select name="proTeamNo" id="proTeamNo" style="width: 210;">
							<c:if test="${positionType=='70'}">
								  <c:forEach items="${teanList}" var="tean">
									<option value="${tean.proTeamNo}">${tean.proTeamName}</option>
								  </c:forEach>
							</c:if>
							<c:if test="${positionType!='70'}">
							<option value="">项目组名称</option>
							<option value="">全部</option>
							<c:forEach items="${teanList}" var="tean">
								<option value="${tean.proTeamNo}">${tean.proTeamName}</option>
							</c:forEach>
							</c:if>
						</select>
					</div>
					<div class="layui-inline">
						<input class="layui-input" style="width: 210" id="bgHappenDate"
							value=""
							onclick="layui.laydate({elem: this, istime: true, format: 'YYYYMMDD'})"
							placeholder="报工日期起始">
					</div>
					<div class="layui-inline">
						<input class="layui-input" style="width: 210" id="endHappenDate"
							value=""
							onclick="layui.laydate({elem: this, istime: true, format: 'YYYYMMDD'})"
							placeholder="报工日期截止">
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-inline">
						<input class="layui-input" id="needNo"
							placeholder="需求编号">
					</div>
					<div class="layui-inline">
						<input class="layui-input"  id="needName"
							placeholder="需求名称">
					</div>
				</div>
				<div class="layui-inline">-</div>
				<div class="layui-inline">
					<button class="layui-btn" type="button" data-method="doSearchSum" id="doSearchSum" >查询</button>
				</div>
			</div>
			<div class="layui-form-item" id="dateDiv">
				<div class="layui-inline">
					<table class="layui-table" lay-even="" lay-skin="line"
						style="text-align: center;width: 100%;">
						<colgroup align="center">
							<col width="10%">
							<col width="15%">
							<col width="10%">
							<col width="6%">
							<col width="6%">
							<col width="8%">
							<col width="8%">
							<col width="8%">
							<col width="8%">
							<col width="6%">
						</colgroup>
						<thead>
							<tr>
								<th>需求编号</th>
								<th>需求名称</th>
								<th>项目组</th>
								<th>需求状态</th>
								<th>人月</th>
								<th>已分配工作量</th>
								<th>待分配工作量</th>
								<th>开始报工日期</th>
								<th>最新报工日期</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="detailDiv">

						</tbody>
						<script id="tplSrc" type="text/html">
							 {{#  layui.each(d.capacityList, function(index, x){}}
							     <tr align="left">
								   <td>{{x.needNo==undefined?'':x.needNo}}</td>
								   <td>{{x.needName==undefined?'':x.needName}}</td>
								   <td>{{x.proTeamName==undefined?'':x.proTeamName}}</td>
									<td>{{x.state==undefined?'':x.state=='01'?'正常':(x.state=='00'?'待审核':(x.state=='03'?'驳回':'需求关闭'))}}</td>
									<td>{{x.renyue==undefined?'':x.renyue}}</td>
									<td>{{x.workload==undefined?'':x.workload}}</td>
									<td>{{x.unWorkload==undefined?'':x.unWorkload}}</td>
									<td>{{x.startDate==undefined?'':x.startDate}}</td>
									<td>{{x.latestDate==undefined?'':x.latestDate}}</td>
								    <td><button  class="layui-btn" type="button" onclick="assign('{{x.needId}}')">分配</button></td>
								 </tr>
							{{#  }); }} 
					   </script>

					</table>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<div id="laypageDiv"></div>
				</div>
			</div><button style="margin: 0px;"></button>
		</form>
	</div>
	<input id="totalNum" type="hidden" name="totalNum" >
</body>
<script type="text/javascript">
var path="<%=commonPath%>";
	var msg = new msgTool();
	layui.use([ 'form', 'layer', 'laytpl', 'laypage', 'laydate' ],
	function() {
	var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
						var form = layui.form(), layer = layui.layer, laypage = layui.laypage, laytpl = layui.laytpl;
						var active = {
							doSearchSum : function() { //搜索
						      	     active.doSearchDetail(1); 
						         }
						         ,doSearchDetail:function(v_curr){ //搜索   
						         if(v_curr==1){
						        	 var getTpl = tplSrc.innerHTML;
						  			var dataObj = {
						  						"startRow" : (v_curr-1)*15,
						  						"pageSize" : 15,
						  						"proTeamNo" : $("#proTeamNo").val(),
						  						"proGroupNo":$("#proGroupNo").val(),
						  						"needNo" : $("#needNo").val(),
						  						"needName" : $("#needName").val(),
						  						"bgHappenDate": $("#bgHappenDate").val(),
						  						"endHappenDate": $("#endHappenDate").val()
						  					};
						  			msg.sendMsg("/page/capacity/searchCapacityInfor.do",dataObj,function(data) {
						  				laytpl(getTpl).render(data.body,function(html) {
						  				    detailDiv.innerHTML = html;
						  					$('#totalNum').val(data.body.count)
						  				});
						  				totalNum = Math.ceil(data.body.count/15);
						  				laypage({
							                   cont: 'laypageDiv'
							                 ,pages:totalNum
							                  ,jump: function(obj,first){
							                	  if(first!=true){
							                	  	active.doSearchDetail(obj.curr); 
							                	  }
							                   }
							                 }); 
						  			}); 
						         }else{
						        	 var getTpl = tplSrc.innerHTML;
							  			var dataObj = {
							  						"startRow" : (v_curr-1)*15,
							  						"pageSize" : 15,
							  						"proTeamNo" : $("#proTeamNo").val(),
							  						"proGroupNo":$("#proGroupNo").val(),
							  						"needNo" : $("#needNo").val(),
							  						"needName" : $("#needName").val(),
							  						"bgHappenDate": $("#bgHappenDate").val(),
							  						"endHappenDate": $("#endHappenDate").val()
							  					};
							  			msg.sendMsg("/page/capacity/searchCapacityInfor.do",dataObj,function(data) {
							  				laytpl(getTpl).render(data.body,function(html) {
							  				    detailDiv.innerHTML = html;
							  					$('#totalNum').val(data.body.count)
							  				});
							  			}); 
						         }	
						         }
	}
	$('.layui-btn').on('click',function() {
		var othis = $(this), method = othis.data('method');
		active[method] ? active[method].call(this,othis) : '';
	});
});
	 function flush(){
	        $('#doSearchSum').click();
	    }
	 function assign(needId) {
	        layer.open({
	            type: 2,
	            title:"产能分配",
	            area: ['65%', '95%'],
	            scrollbar: false,
	            content: '<%=commonPath %>/page/capacity/'+needId+'/assignCapacity.do',
	            success: function (layero, index) {
	            },
	            end: function () {
	            	flush();
	            }
	        });
	    }
	 
</script>

</html>